<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div,
    p {
        width: 300px;
        height: 30px;
        line-height: 30px;
        background: black;
        color: aliceblue;
    }
</style>

<body>
    <button id="btn" >点我
    </button>
    <button  id="cs">别点我
    </button>
    <div>胡歌</div>
    <p>时间</p>
    <script>
        //innerText
        var btn = document.getElementById('btn')
        var div = document.querySelector('div')
        var p = document.querySelector('p')
        var cs=document.getElementById('cs')
        
        btn.onclick = function () {
            div.innerHTML= dat();
        }
        cs.onclick = function () {
            div.innerText = '你是sb？.....';
        }

        
       
        function dat() {
            var date=new Date;
            var year = date.getFullYear();
            var moth = date.getMonth() + 1;
            var dates = date.getDate();
            var arr = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
            var day = date.getDay();
            return '今天是：  ' + year + '年 ' + moth + '月 ' + dates + '日 ' + arr[day];
        }
        p.innerHTML = dat();




        
    </script>
</body>

</html>